{php include wl_template('common/header');}
<div class="page-group">
    <div class="page page-current" id="page-order-detail">
	    <header class="bar bar-nav">
	    	<a class="button button-link button-nav pull-left back" href="{php echo app_url('order/order/list')}"><span class="icon icon-left"></span>返回</a>
	    	<h1 class="title">售后详情</h1>
	  	</header>
    	
		<div class="content" style="overflow-x: hidden;">
			<div id="nav" class="nav">
			    <p class="nav-wrap">
			        <span class="j-nav-item j-nav-status nav-item nav-choose">订单状态</span>
			        <span class="j-nav-item j-nav-detail nav-item ">订单详情</span>
			        <label class="j-nav-bottomline nav-bottomline"></label>
			    </p>
			</div>
			<div id="order-status">
			    <div class="timeline">
				{if (empty($serves))}
		            <div class="timeline-item">
		                <img class="timeline-logo" src="http://p1.meituan.net/xianfu/8adf62cf3cb75f1a4b21380be10af9fa2048.png">
		                <div class="timeline-block">
		                    <i class="timline-block-arrow"></i>
		                    <p class="timeline-title open-popup" id="qrcode" oid="{$order['orderno']}" data-popup=".popup-qrcode">立即申请退款</p>
		                </div>
		            </div>
					{else}
					<div class="timeline-item">
		                <img class="timeline-logo" src="http://p1.meituan.net/xianfu/8adf62cf3cb75f1a4b21380be10af9fa2048.png">
		                <div class="timeline-block">
		                    <i class="timline-block-arrow"></i>
		                    <p class="timeline-title">售后申请已提交<span class="timeline-time">{php echo date('m-d H:i', $serves['servicetime']);}</span></p>
		                    <p class="timeline-sub">等待客服反馈</p>
		                </div>
		            </div>
					{/if}
		            {if !empty($serves['feedtype'])}
		            <div class="timeline-connect timeline-connect-21"></div>
		            <div class="timeline-item">
		                <img class="timeline-logo" src="http://p0.meituan.net/xianfu/794ec85889844239f32764861c56660a2048.png">
		                <div class="timeline-block">
		                    <i class="timline-block-arrow"></i>
		                    <p class="timeline-title">
							{$serves['feedtype']}
							<span class="timeline-time">{php echo date('m-d H:i', $serves['feedtime']);}</span></p>
		                    <p class="timeline-sub">反馈意见：{$serves['servicefeedback']}<br/>
							<span {if !empty($serves['servicelastremark'])||!empty($serves['overtime'])}style="display:none;"{else}style="color:red;"{/if} class="open-popup">再次申述</span>
							<span {if $serves['feedtype']!='部分退款'||!empty($serves['servicelastremark'])||!empty($serves['overtime'])}style="display:none;"{else}style="color:red;"{/if} oid="{$order['orderno']}" id="part_refund">同意退款</span>
							
							</p>
		                </div>
		            </div>
		            {/if}
					
					 {if !empty($serves['servicelastremark'])}
					  <div class="timeline-connect timeline-connect-21"></div>
					<div class="timeline-item">
		                <img class="timeline-logo" src="http://p0.meituan.net/xianfu/794ec85889844239f32764861c56660a2048.png">
		                <div class="timeline-block">
		                    <i class="timline-block-arrow"></i>
		                    <p class="timeline-title">再次申述<span class="timeline-time">{php echo date('m-d H:i', $serves['servicelasttime']);}</span></p>
		                    <p class="timeline-sub">{$serves['servicelastremark']}</p>
		                </div>
		            </div>
					{/if}
					{if !empty($serves['servicelastfeedback'])}
					  <div class="timeline-connect timeline-connect-21"></div>
					<div class="timeline-item">
		                <img class="timeline-logo" src="http://p0.meituan.net/xianfu/794ec85889844239f32764861c56660a2048.png">
		                <div class="timeline-block">
		                    <i class="timline-block-arrow"></i>
		                    <p class="timeline-title">再次反馈：{$serves['servicelastfeedtype']}<span class="timeline-time">{php echo date('m-d H:i', $serves['servicelastfeedtime']);}</span></p>
		                    <p class="timeline-sub">{$serves['servicelastfeedback']}</p>
		                </div>
		            </div>
					{/if}
					{if !empty($serves['overtime'])}
					  <div class="timeline-connect timeline-connect-21"></div>
					<div class="timeline-item">
		                <img class="timeline-logo" src="http://p0.meituan.net/xianfu/794ec85889844239f32764861c56660a2048.png">
		                <div class="timeline-block">
		                    <i class="timline-block-arrow"></i>
		                    <p class="timeline-title">售后完成<span class="timeline-time">{php echo date('m-d H:i', $serves['overtime']);}</span></p>
		                    <p class="timeline-sub"></p>
		                </div>
		            </div>
					{/if}
			    </div>
			    
			    <div class="bottombar-placeholder"></div>
			
			    
			</div>
			
			<div id="order-detail" style="display: none">
			    <div class="orderregion">
			        <a class="status-hotelname" href="#">
			            <i class="icon1-detail status-hotelname-icon"></i>
			            <label class="status-hotelname-name">{$order['merchant_name']}</label>
			            <i class="icon-arrow-right-thin status-hotelname-back"></i>
			        </a>
			    </div>
			    
			    <div class="orderregion orderregion-top">
			        <ul class="orderregion-entries">
					{if $order['g_id']>0}
			            <li class="orderregion-entry">
			                <span class="name text-overflow-ellipsis-2">{$goods['gname']}</span>
			               <!-- <span class="price">￥{php echo $goods['gprice']*$order['gnum']}</span>-->
			                <span class="price" >{if $order['is_tuan']==0}{$goods['oprice']}{elseif $order['is_tuan']==1}{$goods['gprice']}{/if}×{$order['gnum']}</span>
			            </li>
						{else}
						<?php 
								$col=pdo_fetchall("select * from ".tablename('tg_collect')." where  orderno=:orderno",array('orderno'=>$order['orderno']));
								?>
								 {loop $col $v}
								 <?php 
								$gs=pdo_fetch("select * from ".tablename('tg_goods')." where  id=:id",array('id'=>$v['sid']));
								
								?>
								<li class="orderregion-entry">
			                <span class="name text-overflow-ellipsis-2">{$gs['gname']}</span>
							 <span class="name text-overflow-ellipsis-2">规格：{$v['item']}</span>
			               <!-- <span class="price">￥{php echo $goods['gprice']*$order['gnum']}</span>-->
			                <span class="price" >{$v['oprice']}×{$v['num']}</span>
			            </li>
						
								 {/loop}
						{/if}
			        </ul>
			    </div>
			<?php 
								$refund=pdo_fetch("select * from ".tablename('tg_order_level_refund')." where  orderno=:orderno",array('orderno'=>$order['orderno']));
							$realprice=	round($order['pay_price'],2)-round($refund['refundprice'],2);
								?>
			    <div class="orderregion">
			        <ul class="orderregion-entries">
					{if $gs['selltype']==4}
					 <li class="orderregion-entry order-other-price">
			                <span class="name text-overflow-ellipsis-2">返还</span>
			                <span class="price">￥&nbsp;{$refund['refundprice']}</span>
			            </li>
						{/if}
			            <li class="orderregion-entry order-other-price">
			                <span class="name text-overflow-ellipsis-2">运费</span>
			                <span class="price">￥&nbsp;{$order['freight']}</span>
			            </li>
			            <li class="orderregion-entry order-total-price">
			                <span class="name text-overflow-ellipsis-2">合计</span>
			                <span class="price">￥&nbsp;{$realprice}</span>
			            </li>
			        </ul>
			    </div>

			    <!--门店-->
	            {if $order['is_hexiao'] != 0}
	            <div class="orderregion">
			        <h1 class="orderregion-title">
			            <i class="icon1-detail status-detail-icon"></i>
			            <label class="status-name">核销信息</label>
			        </h1>
			        <ul class="orderregion-entries-compact">
					 <li class="orderregion-entry-compact">
			                <span class="label">收货人：</span>{$order['addname']}&nbsp; {$order['mobile']}
			            </li>
					 
					 <li class="orderregion-entry-compact">
			                <span class="label">提货点：</span>{$sto['storename']}
			            </li>
			           <li class="orderregion-entry-compact">
			                <span class="label">核销员：</span>{$sal['nickname']}
			            </li>
			            <li class="orderregion-entry-compact" id="hexiaotime">
			                <span class="label">核销时间：</span>{php echo date('Y-m-d H:i:s', $order['hexiaotime']);}
			            </li>
			        </ul>
			    </div>
				<!--<div class="good_speci" onclick="showStores(this)" show="1">适用的商家信息<i class="fa fa-angle-down" style="float:right; line-height:44px; font-size:26px;"></i></div>
	  			<div>
		  			{loop $stores $stores}
			        <div class="store">
			            <div class="info">
			            <div class="ico"><i class="fa fa-university"></i></div>
			            <div class="info1">
			                <div class="inner">
			                     <div class="user">{$stores['storename']}</div>
			                     <div class="addresss">地址: {$stores['address']}</div>
			                     <div class="tel">电话: {$stores['tel']}</div>
			                 </div>
			             </div>
			             <a href="http://api.map.baidu.com/marker?location={$stores['lat']},{$stores['lng']}&amp;title={$stores['storename']}&amp;name={$stores['storename']}&amp;content={$stores['address']}&amp;output=html" class="external"><div class="ico2"><i class="fa fa-map-marker"></i></div></a>
			             <a href="tel:{$stores['tel']}" class="disable-router"><div class="ico3"><i class="fa fa-phone"></i></div></a>
			        	</div>
			        </div>
					{/loop}
		       	</div>-->
		       	{else}
		       	<div class="orderregion">
			        <h1 class="orderregion-title">
			            <i class="icon1-detail status-detail-icon"></i>
			            <label class="status-name">配送信息</label>
			        </h1>
			        <ul class="orderregion-entries-compact">
			            <li class="orderregion-entry-compact">
			                <span class="label">收货人：</span>{$order['addname']}&nbsp; {$order['mobile']}
			            </li>
			            <li class="orderregion-entry-compact">
			                <span class="label">收货地址：</span>{$order['address']}
			            </li>
			        </ul>
			    </div>
		       	{/if}
		       	
			    <div class="orderregion">
			        <h1 class="orderregion-title">
			            <i class="icon1-detail status-detail-icon"></i>
			            <label class="status-name">订单详情</label>
			        </h1>
			        <ul class="orderregion-entries-compact">
			            <li class="orderregion-entry-compact">
			                <span class="label">订单号码：</span>{$order['orderno']}
			            </li>
			            <li class="orderregion-entry-compact">
			                <span class="label">下单时间：</span>{php echo date('Y-m-d H:i:s', $order['createtime']);}
			            </li>
			            <li class="orderregion-entry-compact">
			                <span class="label">支付方式：</span>微信支付
			            </li>
			            {if $order['remark']}
			            <li class="orderregion-entry-compact">
			                <span class="label">备注：</span>{$order['remark']}
			            </li>
			            {/if}
			        </ul>
			    </div>

			    <div class="buy-again-placeholder"></div>
			    </div>
			</div>
		</div>
	</div>
</div>
<div class="popup popup-qrcode" id="div-qrcode">
  	<div class="content" style="background: #eee;">
	
    	<div class="list-block cards-list">
	      <ul>
		  
	        <li class="card" style="border-radius: .2rem;">
	          <div class="card-header"><h3 class="font-size-14">申请退款</h3></div>
	          <div class="card-content">
	            <div class="card-content-inner">
				<div class="item-content">
		            <div class="item-inner">
		              <div class="item-title label">退款原因：</div>
		              <div class="item-input">
		                <select id="servicereson">
		                 <option value="" >请选择退款原因</option>
                                <option value="不想买了" {if $serves['servicereson']=="不想买了"} selected="selected"{/if}>不想买了</option>
								<option value="商品错拍" {if $serves['servicereson']=="商品错拍"} selected="selected"{/if}>商品错拍</option>
								
		                </select>
		              </div>
					  
		            </div>
					
		          </div>
			        
			        <div class="voucher-address font-size-14">
					 <div class="item-inner">
		              <div class="item-title label">申请理由：</div>
		              <div class="item-input">
		               <textarea name="serviceremark" id="serviceremark" style="height: 60px;width:220px;" placeholder="请添加申请理由" >{$serves['serviceremark']}</textarea>                     
						
		              </div>
		            </div>
			        </div>
					
					<div class="voucher-address font-size-14" {if empty($serves['serviceremark'])}style="display:none"{/if}>
					 <div class="item-inner">
		              <div class="item-title label">再次申诉理由：</div>
		              <div class="item-input">
		               <textarea name="servicelastremark" id="servicelastremark" style="height: 60px;width:220px;" placeholder="请添加再次申诉理由" >{$serves['servicelastremark']}</textarea>                     
						
		              </div>
		            </div>
			        </div>
					
					{if $order['g_id']>0}
			        <div class="voucher-goods-info font-size-14">
			            <p>商品名称：{$goods['gname']} </p>
						{if !empty($order['optionname'])}<p>商品规格：{$order['optionname']} </p>{/if}
						<p>数量：{$order['gnum']}</p>
				        <p>实付金额：{$order['pay_price']}元</p>
				        </div>
				    
					{else}
					
				   <?php 
								$col=pdo_fetchall("select * from ".tablename('tg_collect')." where  orderno=:orderno",array('orderno'=>$order['orderno']));
								?>
								 {loop $col $v}
								 <?php 
								$gs=pdo_fetch("select * from ".tablename('tg_goods')." where  id=:id",array('id'=>$v['sid']));
								?>
									
									 <div class="voucher-goods-info font-size-14">							
										<p>{$gs['gname']}</p>
										<p>{if !empty($v['item'])}规格：{$v['item']},{/if}</p>
										<p>数量:{$v['num']},单价:{$v['oprice']}</p>
										
										<hr style="margin-top: 10px;margin-bottom: 0px;"/>
									</div>
									
								 {/loop}
					{/if}
					 </div>
	          </div>
	        </li>
	      </ul>
	    </div>
	    <div class="weui_btn_area">
        	<a class="weui_btn weui_btn_warn " id="btn_serves" oid="{$order['orderno']}">提交</a>
			<a class="weui_btn weui_btn_warn close-popup" id="close-p" style="display:none">关闭</a>
    	</div>
  	</div>
</div>
<script>

{if (empty($serves))}
window.onload = function () {

	var popupQrcode = document.getElementsByClassName("popup popup-qrcode")[0];

	  popupQrcode.classList.add("modal-in");
	  popupQrcode.style.display = 'block';
	
}
{/if}
$(document).on('click','#qrcode',function(){
$("#div-qrcode").show();

	});
$(document).on('click','#part_refund',function(){
var orderno = $(this).attr('oid');
var feedbackfee = $("#feedbackfee").val();
$.post("{php echo app_url('order/serves/part_refund')}",{orderno:orderno,feedbackfee:feedbackfee},function(d){
					if(d.status == 1){					
					   $.toast(d.result);
						location.reload();
					}else{
						$.toast(d.result);
					}
				},"json");
	});
$(document).on('click','#btn_serves',function(){
	var orderno = $(this).attr('oid');
	var servicereson = $("#servicereson").val();
	var serviceremark = $("#serviceremark").val();
	var servicelastremark = $("#servicelastremark").val();
	$.confirm('是否申请退款？',
	        function () {
	          	$.post("{php echo app_url('order/serves/check')}",{orderno:orderno,servicereson:servicereson,serviceremark:serviceremark,servicelastremark:servicelastremark},function(d){
					if(d.status == 1){
					$("#close-p").click();
					    $.toast('申请成功，请等待客服审核！');
					    location.reload();
					}else{
						$.toast(d.result);
					}
				},"json");
	        }
	    );
	
});
$(".j-nav-status").bind('click', function() {
		$('.j-nav-status').addClass('nav-choose');
		$('.j-nav-detail').removeClass('nav-choose');
		$('.j-nav-bottomline').removeClass('nav-bottomlineright').addClass('nav-bottomline');
		$('#order-status').show();
		$('#order-detail').hide();
	});
	$(".j-nav-detail").bind('click', function() {
		$('.j-nav-detail').addClass('nav-choose');
		$('.j-nav-status').removeClass('nav-choose');
		$('.j-nav-bottomline').removeClass('nav-bottomline').addClass('nav-bottomlineright');
		$('#order-status').hide();
		$('#order-detail').show();
	});
</script>
{php include wl_template('common/footer');}